/*
 * 1. Разбиение на компоненты связности.
 * 2. Проверка на двудольность. (<<<)
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N_MAX	100000
#define M_MAX	100000

#define DFS_NOT_BIPARTITE (1 << 1)
#define DFS_BIPARTITE     (1 << 2)
#define DFS_CONT          (1 << 3)

struct Node {
	int x;
	Node *next;
};

struct adjlist {
	Node *first;
	Node *last;
	int size;
	int color;
	int visited;
	int distance;
};

static const char *colors[] = {
	NULL,
	"RED",
	"BLACK",
	NULL
};

void
pushback(struct adjlist *al, int x)
{
	Node *newnode;

	newnode = (Node *) malloc(sizeof (Node));
	newnode->x = x;
	newnode->next = NULL;
	if (!al->first)
		al->first = newnode;
	else
		al->last->next = newnode;
	al->last = newnode;
	al->size++;
}

void
free_al(struct adjlist *al)
{
	struct Node *n, *p;
	p = n = al->first;
	while (n) {
		n = n->next;
		free(p);
		p = n;
	}
}

void
listprint(struct Node *node)
{
	while (node) {
		printf("%d%s", node->x + 1, node->next ? " -> " : "\n");
		node = node->next;
	}
}

int
dfs_bipartition(struct adjlist *al, const int n, const int s,
		const int distance)
{
	Node *nd;
	int ret = 0;

	al[s].distance = distance;
	al[s].visited  = 1;
	nd = al[s].first;

	while (nd) {
		if (al[nd->x].visited &&
		    (al[nd->x].distance & 1) == (distance & 1)) {
			return (DFS_NOT_BIPARTITE);
		} else if (al[nd->x].visited) {
			return (DFS_CONT); //nowhere to to go
		} else {
			ret = dfs_bipartition(al, n, nd->x, distance + 1);
			if (ret == DFS_NOT_BIPARTITE)
				return (DFS_NOT_BIPARTITE);
			if (ret == DFS_CONT) {
				fprintf(stderr, "dfs_bipartition(al=%p, n=%d, s=%d, distance=%d)"
						" returned DFS_CONT\n",
						al, n, nd->x, distance + 1);
			}
		}
		nd = nd->next;
	}

	return (DFS_CONT);
}

int
main(void)
{
	static struct adjlist AL[N_MAX];
	static char line[1024], *read_ptr;
	int n = 0, m = 0;
	int i = 0;
	int vtx_id, vtx_ref;

	do {
		read_ptr = fgets(line, 1024, stdin);
	} while (sscanf(line, "%d %d", &n, &m) != 2);

	while (i < m) { //HAHAUEUHAEHUAEHAUEHAEUHAEUHAEUHAUEH
		read_ptr = fgets(line, 1024, stdin);
		if (sscanf(read_ptr, "%d", &vtx_id) != 1)
			continue;
		while (read_ptr = strchr(read_ptr, ' '), read_ptr) {
			if (sscanf(++read_ptr, "%d", &vtx_ref) != 1)
				break;
			pushback(&AL[vtx_id - 1], vtx_ref - 1);
			pushback(&AL[vtx_ref - 1], vtx_id - 1);
		}
		i++;
	}

	fprintf(stderr, " n=%d\n", n);
	for (i = 0 ; i < n ; ++i)
		AL[i].visited = AL[i].distance = 0;

	switch (dfs_bipartition(AL, n, vtx_id - 1, 0)) {
	case DFS_NOT_BIPARTITE:
		puts("NO");
		break;
	//case DFS_CONT:
	//case DFS_BIPARTITE:
	default:
		puts("YES");
		break;
	}

	for (i = 0 ; i < n ; ++i)
		free_al(&AL[i]);

	return (0);
}
